package priv.mill.xml;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class TestXmlConfig {

	private static final Logger logger = Logger.getLogger(TestXmlConfig.class);

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		
//		parseDate();
		
		ApplicationContext context
		= new FileSystemXmlApplicationContext("classpath:ioc-test.xml");
		//名称注入和类型注入，一般情况下用类型注入，当不是单例的时候，同一个类型有多个配置的时候就要用名称注入
//		Person bean = (Person) context.getBean("person");
		/*
		BanJi bean2 = context.getBean(BanJi.class);
		Book bean4 = (Book) context.getBean("kenanbook");
		Book bean3 = (Book) context.getBean("nuxun");
		DbConfig bean5 = context.getBean(DbConfig.class);
		bean5.print();
		Car bean6 = context.getBean(Car.class);*/
//		Object bean1 = context.getBean("maxnum");
		Package bean = context.getBean(Package.class);
		System.out.println(bean);
	}

	private static void parseDate() {
		try {
			Date parse = new SimpleDateFormat("yyyy-MM-dd").parse("2018-4-9");
			System.out.println(parse);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
